﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:variable name="nrOfActors">10</xsl:variable>

  <xsl:output method="html"/>

  <xsl:param name="pageheight">200</xsl:param>
  <xsl:param name="pagewidth">400</xsl:param>

  <xsl:include href="shared_templates.xsl"/>

  <!-- the main template -->
  <xsl:template match="/">
    <HTML>
      <HEAD>
        <LINK REL="StyleSheet" TYPE="text/css" HREF="view_item_details_aqua2.css"></LINK>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <TITLE>Movie</TITLE>
      </HEAD>
      <BODY marginheight="0" marginwidth="0" leftmargin="5" rightmargin="5" topmargin="3" bottommargin="5" border="0" class="bodybg">
        <xsl:apply-templates/>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="movieInfo">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" class="maintable">
      <tr>
        <td>
          <table border="0" cellspacing="1" cellpadding="0" width="100%">
            <tr>
              <td class="maintitle" width="100%">
                <xsl:value-of select="title"/>
                <xsl:if test="year!=''">
                  <xsl:text> (</xsl:text><xsl:value-of select="year"/>)
                </xsl:if>
              </td>
            </tr>
          </table>

          <xsl:if test="tagline!=''">
            <table border="0" cellspacing="1" cellpadding="0" width="100%">
              <tr>
                <td class="tagtitle" width="100%">
                  <xsl:value-of select="tagline"/>
                </td>
              </tr>
            </table>
          </xsl:if>

          <!-- IMDB Rating -->
          <table border="0" cellspacing="1" cellpadding="0" width="100%">
            <xsl:if test="imdbRating!=''">
              <tr valign="center">
                <td class="cellalt1" nowrap="1" width="5%">
                  <xsl:value-of select="/movieInfo/metadata/field[@name='imdbRating']/@label"/>
                </td>
                <td class="stars" width="10%" nowrap="1">
                  <xsl:choose>
                    <xsl:when test="contains(imdbRating,' ')">
                      <xsl:call-template name="starIMDB">
                        <xsl:with-param name="numIMDB" select="substring-before(imdbRating,' ')"/>
                      </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:call-template name="starIMDB">
                        <xsl:with-param name="numIMDB" select="imdbRating"/>
                      </xsl:call-template>
                    </xsl:otherwise>
                  </xsl:choose>
                </td>
                <td class="cellalt1" width="25%">
                  <xsl:value-of select="imdbRating"/>
                </td>
              </tr>
            </xsl:if>
          </table>

          <table border="0" cellspacing="1" cellpadding="0" width="100%">
            <tr>
              <xsl:if test="picture!=''">
                <td class="subtitle" height="17">
                  <xsl:value-of select="/movieInfo/metadata/field[@name='picture']/@label"/>
                </td>
              </xsl:if>
              <td class="subtitle" height="17" align="left">
                <xsl:value-of select="/movieInfo/metadata/field[@name='actors']/@label"/>
              </td>
            </tr>
            <tr valign="top">
              <xsl:if test="picture!=''">
                <td width="1" class="detailsbg">
                  <img src="{picture}" border="0" height="200"/>
                </td>
              </xsl:if>
              <td class="detailsbg" valign="top">
                <xsl:if test="actors!=''">
                  <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <tr valign="top">
                      <td>
                        <table border="0" cellspacing="1" cellpadding="0" width="100%">
                          <xsl:for-each select="actors/actor[position() &lt;= $nrOfActors]">
                            <tr>
                              <td class="cellvalue" width="10%" nowrap="1">
                                <xsl:value-of select="node()" />
                              </td>
                            </tr>
                          </xsl:for-each>
                        </table>
                      </td>
                    </tr>
                  </table>
                </xsl:if>
              </td>
            </tr>
          </table>

          <xsl:if test="description!=''">
            <table border="0" cellspacing="1" cellpadding="0" width="100%">
              <tr>
                <td class="subtitle" height="17" align="left">
                  <xsl:value-of select="/movieInfo/metadata/field[@name='description']/@label"/>
                </td>
              </tr>
              <tr>
                <td class="plot" colspan="2">
                  <xsl:call-template name="break">
                    <xsl:with-param name="text" select="description"/>
                  </xsl:call-template>
                </td>
              </tr>
            </table>
          </xsl:if>

          <table border="0" cellspacing="1" cellpadding="0" width="100%">
            <tr>
              <td valign="top" class="detailsbg" width="50%">
                <table border="0" cellspacing="1" cellpadding="0" width="100%">
                  <tr>
                    <td class="subtitle" height="17" align="left" colspan="2">
                      <xsl:value-of select="/movieInfo/metadata/field[@name='movieInfo']/@label"/>
                    </td>
                  </tr>
                  <xsl:if test="genres!=''">
                    <tr valign="top">
                      <td width="10%" nowrap="1" class="celllabel">
                        <xsl:value-of select="/movieInfo/metadata/field[@name='genres']/@label"/>
                      </td>
                      <td class="cellvalue">
                        <xsl:for-each select="genres/genre">
                          <xsl:value-of select="node()" />
                          <xsl:if test="position()!=last()">
                            <xsl:text>; </xsl:text>
                          </xsl:if>
                        </xsl:for-each>
                      </td>
                    </tr>
                  </xsl:if>
                  <xsl:if test="director!=''">
                    <tr valign="top">
                      <td width="10%" nowrap="1" class="celllabel">
                        <xsl:value-of select="/movieInfo/metadata/field[@name='director']/@label"/>
                      </td>
                      <td class="cellvalue">
                        <xsl:value-of select="director"/>
                      </td>
                    </tr>
                  </xsl:if>
                  <xsl:if test="writer!=''">
                    <tr valign="top">
                      <td width="10%" nowrap="1" class="celllabel">
                        <xsl:value-of select="/movieInfo/metadata/field[@name='writer']/@label"/>
                      </td>
                      <td class="cellvalue">
                        <xsl:apply-templates select="writer"/>
                      </td>
                    </tr>
                  </xsl:if>
                  <xsl:if test="mpaaRating!=''">
                    <tr valign="top">
                      <td class="celllabel" width="10%" nowrap="1">
                        <xsl:value-of select="/movieInfo/metadata/field[@name='mpaaRating']/@label"/>
                      </td>
                      <td class="cellvalue">
                        <xsl:value-of select="mpaaRating"/>
                      </td>
                    </tr>
                  </xsl:if>
                  <xsl:if test="runtime!=''">
                    <tr valign="top">
                      <td class="celllabel" width="10%" nowrap="1">
                        <xsl:value-of select="/movieInfo/metadata/field[@name='runtime']/@label"/>
                      </td>
                      <td class="cellvalue">
                        <xsl:value-of select="runtime"/>
                        <xsl:text> </xsl:text><xsl:value-of select="/movieInfo/metadata/field[@name='runtimeUnit']/@label"/>
                      </td>
                    </tr>
                  </xsl:if>

                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>

  </xsl:template>
</xsl:stylesheet>